<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/12/15
  Time: 17:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>客户服务创建</title>
    <!-- 引入样式和 js  -->
    <jsp:include page="../common/css_js.jsp"/>
    <jsp:include page="../common/table.jsp"/>
    <style>
        table th {
            font-size: 15px;
            min-width: 100px;
            text-align: right;
        }
    </style>
</head>
<body>
<div class="container col-lg-12 ">
    <div class="card">
        <header class="card-header">
            <div class="card-title"><h4><b>服务创建</b></h4></div>
        </header>
        <div class="card-body">
            <div class="row clearfix">
                <div class="col-md-7 column">
                    <!-- 数据显示 -->
                    <form>
                        <table class="table table-hover">
                            <tr>
                                <th>服务类型：</th>
                                <td>
                                    <label>
                                        <select name="serviceType" class="form-control text-dark">
                                            <option value="">请选择服务类型</option>
                                            <option value="咨询">咨询</option>
                                            <option value="投诉">投诉</option>
                                            <option value="建议">建议</option>
                                        </select>
                                    </label>
                                </td>
                            </tr>
                            <tr>
                                <th>所属客户：</th>
                                <td>
                                    <label>
                                        <select name="customer" id="sel-customer" class="form-control text-dark">
                                        </select>
                                    </label>
                                </td>
                            </tr>
                            <tr>
                                <th>服务内容：</th>
                                <td colspan="3">
                                    <label>
                                        <textarea name="serviceRequest" class="form-control" rows="4" cols="60"
                                                  placeholder="请输入服务内容"></textarea>
                                    </label>
                                </td>
                            </tr>
                            <tr>
                                <th>详细信息：</th>
                                <td colspan="3">
                                    <label>
                                        <textarea name="overview" class="form-control" rows="4" cols="60"
                                                  placeholder="请输入服务信息"></textarea>
                                    </label>
                                </td>
                            </tr>
                            <tr>
                                <th>是否有效：</th>
                                <td>
                                    <div class='custom-control custom-radio custom-control-inline'>
                                        <input type='radio' id='customRadioInline6' name='isValid' value='1'
                                               class='custom-control-input' checked='checked'>
                                        <label class='custom-control-label' for='customRadioInline6'>有效</label>
                                    </div>
                                    <div class='custom-control custom-radio custom-control-inline'>
                                        <input type='radio' id='customRadioInline7' name='isValid' value='0'
                                               class='custom-control-input'>
                                        <label class='custom-control-label' for='customRadioInline7'>无效</label>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <button type="reset" class="btn btn-primary"><span class="mdi mdi-refresh"></span>重置
                                    </button>
                                    <button style="margin-left: 80px" type="button" class="btn btn-primary" id="save">
                                        <span class="mdi mdi-checkbox-marked-outline"></span>确定
                                    </button>
                                </td>
                            </tr>
                            <input type="hidden" name="state" value="1"/>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        // 获取所有客户
        $("#sel-customer").append("<option value=''>请选择客户</option>");
        $.get("${ctx}/customer/list", function (data) {
            $(data.data).each(function (i, o) {
                $("#sel-customer").append("<option value='" + o.customerName + "'>" + o.customerName + "</option>");
            });
        });

        // 保存
        $("#save").click(function () {
            let $customer = $("[name='customer']");
            let $type = $("[name='serviceType']");
            let $request = $("[name='serviceRequest']");

            if ($type.val() === '') {
                notify("mdi mdi-close", "请选择服务类型！", "danger");
                $type.focus();
            } else if ($customer.val() === '') {
                notify("mdi mdi-close", "请选择客户！", "danger");
                $customer.focus();
            } else if ($request.val() === '') {
                notify("mdi mdi-close", "服务内容不能为空！", "danger");
                $request.focus();
            } else {
                let $form = $("form")
                saveOrUpdate("${ctx}/customer-service/create", $form.serializeArray());
                $form[0].reset();
            }
        });
    });
</script>
</body>
</html>
